
        var createRequest = function( handler, request, object, callback )
           {
				switch(handler)	
				{
					case 'Project': {
						return core.projects.handler(request, object, callback);
					} break;

					case 'User': {
						return core.users.handler(request, object, callback);
					} break;
				}
				
		   
                //handler - project
				//				|___ Target
				//				|		|
				//				|		|_____ Ticket
				//				|	
				//				|___ Group
				//					|
				//					|____User
				
				//request - create / edit / delete / link / fetch / list / listall
				
				//object - json data to transport
				
				//callback - where to take the data when it arrives
				
				//examples :
					// Project fetch { id : '20' }									// Fetch the project into an object
					// User edit { id : '20', passwd : 'new' }						// Change user password to something new, emailing them
					// Ticket link { id:'12', id:'23' , id:'31'  }  				// Link ticket 12 to the others. These tickets to be related/similar.
					// Ticket edit { id:'12', node:'6', node:'8', progress:'100' }  // Set node 6 and 8 to 100% complete.
		   
		//Project - 
			// id 
			// desc
			// name
			// created
			// created by
			// group list
			// user list
				
			//Target -
				// id
				// desc
				// date
				// created
				// created by
				// group list
				// user list	

						//Ticket -
							// id
							// name
							// lead
							// description
							// project
                            // created
							// createdBy
							// status
							// user list  // assigned to list
							// progress   // overall progress of all nodes
							// internalStatus
							// tags
							
						//Ticket Node - 
							// id 
							// name
							// desc
							// ticket
							// deadline
							// progress	//per node, per user
							// user list
							// tags
				
			//Group -
				// id
				// user list
				// desc
				// name
				
						//User -
							// id 
							// email
							// username
							// passwd
							// last login
							// access level
							// status
							// groups
							// current ticket
           }				

/* Cause a request string to occur*/
function happen(request, callback)
{
	//Unroll the string into a valid request.
		var tmp = request;
		var h = tmp.indexOf(' ');
		
	var han = tmp.substr(0, h);
			tmp = tmp.substr(h+1, tmp.length);
			h = tmp.indexOf(' ');
			
	var req = tmp.substr(0, h);
			tmp = tmp.substr(h+1, tmp.length);
			
	var obj = tmp.substr(0, tmp.length);

	return createRequest(han, req, obj, callback);
}

/* Wraps an object into JSON */
function down(o)
{
	return JSON.encode(o);
}

/* Unwraps an object into JSON */
function up(o)
{
	return JSON.decode(o);
}

/* Groups a group of properties into a single JSON type string */
function group(name, arr)
{
	if($type(arr) == 'array')
	{
		//If we are given a list like ids: 12, 15, 36, 74
		//We just wrap it like this {'id':'12', 'id':'15', id':'36', id':'74'}
		str = '{';
		count = arr.length;
		for(i = 0; i < count; ++i)
		{
			str += '\''+name+'\':\''+arr[i]+'\'';
			if(i != count - 1)
			{
				str += ' , ';
			}
		}
		str += '}';
		return str;
	}
}

/* Ungroups a group of properties, returns an array of the values */
function ungroup(str)
{
	var items = new Array();
	//first cut the string up into 'name':'value'
	var a = str.split(',');
	//find the :' and delete anything before,
	//then find the ' and delete anything after
	for(i = 0; i < a.length; ++i)
	{
		var pos = a[i].indexOf(':');
		a[i] = a[i].substr(pos+2, a[i].length );
		pos = a[i].indexOf('\'');
		a[i] = a[i].substr(0, pos );
		items[i] = a[i];
	}
	
	return items;
}